package com.ibangnuo.manage.controller.terminal;

import com.ibangnuo.api.terminal.TerminalControllerApi;
import com.ibangnuo.framework.domain.Terminal;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.terminal.TerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author:ly
 * @Data:2020/1/2 12:00
 * @Verdion:1.0
 */
@RestController
@RequestMapping("/terminalEntity")
public class TerminalController implements TerminalControllerApi {

    @Autowired
    private TerminalService terminalService;


    @Override
    @PostMapping("/terminalQuery")
    public QueryResponseResult query(@RequestBody Map map) {
        return terminalService.query(map);
    }

    @Override
    @GetMapping("/name")
    public QueryResponseResult query() {
        return terminalService.findName();
    }

    @Override
    @PostMapping("/addTerminal")
    public QueryResponseResult addTerminal(@RequestBody Map map) {
        return terminalService.addTerminal(map);
    }

    @Override
    @GetMapping("/delTerminal/{terminalUuid}")
    public QueryResponseResult delTerminal(@PathVariable("terminalUuid") String id) {
        return terminalService.delTerminal(id);
    }

    @Override
    @GetMapping("/findById/{id}")
    public QueryResponseResult findById(@PathVariable("id") String id) {
        return terminalService.findById(id);
    }

    @Override
    @PostMapping("/upTerminal")
    public QueryResponseResult upTerminal(@RequestBody Map map) {
        return terminalService.upTerminal(map);
    }

    /**
     * 根据sn号查询商户是否授权
     * @param sn
     * @return
     */
    @GetMapping("/findBySnNum/{sn}")
    @Override
    public ObjectResult findPidBySnNum(@PathVariable("sn") String sn) {
        return terminalService.findPidBySnNum(sn);
    }

    /**
     * 门店查询
     * @param sn
     * @return
     */
    @GetMapping("/findShopBySnNum/{sn}")
    @Override
    public ObjectResult findShopBySnNum(@PathVariable String sn) {
        return terminalService.findShopBySnNum(sn);
    }

    /**
     * 新版机具添加
     * @param terminal
     * @return
     */
    @PostMapping("/addNew")
    @Override
    public ResponseResult addNew(@RequestBody Terminal terminal) {
        return terminalService.addNew(terminal);
    }

    /**
     * 器具查询新版
     * @param map
     * @return
     */
    @PostMapping("/findListNew")
    @Override
    public QueryResponseResult findByListNew(@RequestBody Map map) {
        return terminalService.findListNew(map);
    }

    /**
     * 器具查询新版1
     * @param map
     * @return
     */
    @PostMapping("/findListNew2")
    @Override
    public QueryResponseResult findListNew2(@RequestBody Map map) {
        return terminalService.findListNew2(map);
    }


}
